package cn.edu.sjtu.stap.cfg.builder;

import java.util.*;

import org.aspectj.org.eclipse.jdt.internal.compiler.ast.*;

import cn.edu.sjtu.stap.cfg.ControlFlowGraph;
import cn.edu.sjtu.stap.cg.CallGraph;

/**
 * Interface of CFG builder. It defines a sequence of methods for CFG
 * construction. It also provides methods to carry out initialization and fetch
 * results.
 * 
 * @author William
 * 
 */
public interface ICfgBuilder {
    /**
     * Initialize this builder.
     * 
     */
    public void initialize();

    /**
     * Build intra-module CFGs for all the modules in the given AST.
     * 
     * @param unit
     *            the AST to build intra-module CFGs for.
     */
    public void buildIntraModuleCfg(CompilationUnitDeclaration unit);

    /**
     * Get the intra-module CFGs that have been built by
     * <code>buildIntraModuleCfg</code>.
     * 
     * @return Map of intra-module CFGs for each module.
     */
    public Map<AbstractMethodDeclaration, ControlFlowGraph> getIntraModuleCfgs();

    /**
     * Build inter-module CFGs for the entire system starting at entry methods.
     * 
     * @param cgs
     *            Call graphs for each module.
     * @param cfgs
     *            Intra-module CFGs for each module.
     * @param entries
     *            Program entries of the system, where the inter-module CFGs
     *            start.
     */
    public void buildInterModuleCfg(Map<AbstractMethodDeclaration, CallGraph> cgs,
            Map<AbstractMethodDeclaration, ControlFlowGraph> cfgs, Set<AbstractMethodDeclaration> entries);

    /**
     * Get the inter-module CFGs that have been built by
     * <code>buildInterModuleCfg</code>.
     * 
     * @return Map of inter-module CFGs for each entry method.
     */
    public Map<AbstractMethodDeclaration, ControlFlowGraph> getInterModuleCfgs();
}
